<%@ page import="java.util.List" %>
<%@ page import="entity.Message" %><%--
  Created by IntelliJ IDEA.
  User: zhouya
  Date: 2019/6/25/0025
  Time: 1:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="../js/common.js"></script>
    <style>
        table{border: 1px solid gray;border-collapse: collapse;width: 100% }
        td{border: 1px solid gray;text-align: center;}
        a {color: #01040c; text-decoration:none;}
        a:visited {text-decoration:none;}
        a:hover {color:#ba2636;text-decoration:underline;}
        a:active {color:#ba2636;}

        #page_box{
            height: 25px;
            border: 1px solid #9cc8ec;
            background-color: white;
        }
    </style>
    <%
        List<Message> list=(List<Message>)request.getAttribute("list");
        int current_page = (int)request.getAttribute("page");
        int sum = (int)request.getAttribute("sum");
        int num_every_page = (int)request.getAttribute("num_every_page");
        int last_page = (int)request.getAttribute("last_page");
    %>
</head>
<body>
<div>
    <table bgcolor="white">
        <tr>
            <td>留言ID</td>
            <td>创建时间</td>
            <td>留言内容</td>
            <td>操作</td>
        </tr>
        <%for(Message ls:list){%>
        <tr>
            <td><%=ls.getMessageId()%></td>
            <td><%=ls.getCreateDate()%></td>
            <td><%=ls.getContent()%></td>
            <td>
                <a href="AdminMessageDetailServlet?messageId=<%=ls.getMessageId()%>">详情</a>
                <a href="AdminMessageUpdateServlet?status=2&messageId=<%=ls.getMessageId()%>&newStatus=3">取消发布</a>
            </td>
        </tr>
        <%}%>
    </table>

    <form action="AdminAllMessageServlet" method="post" id="page_box" >
        <input type="text" style="display: none;" id="current_page" value="<%=current_page%>" />
        <input type="text" style="display: none;" id="last_page" value="<%=last_page%>" />
        <input type="text" style="display: none;" name="page" id="next_page" />
        <input type="text" style="display: none" name="status" value="2" />

        <input type="submit" style="margin-left:350px;border: 0;width: 9px;background-image: url('../image/first_page.png')" onclick="to_first_page()" id="page_first_btn" value="">
        <input type="submit" style="border: 0;width: 11px;background-image: url('../image/page_up.png')"  onclick="page_up()" id="page_up_btn" value=""> |
        <input type="text" value="<%=current_page %>" style="width: 32px;height: 18px;border: 1px solid #abadb3">
        <span style="color:royalblue">共<%=last_page %>页</span>|
        <input type="submit" style="border: 0;width: 11px;background-image: url('../image/page_down.png')" onclick="page_down()" id="page_down_btn" value="">
        <input type="submit" style="border: 0;width: 9px;background-image: url('../image/last_page.png')" onclick="to_last_page()" id="page_last_btn" value="">
        <select id="pages" onchange="submitForm(); ">
            <%for(int i = 1; i <= last_page; i++){%>
            <option  value="<%=i %>" <%if(i == current_page){%> selected <%}%> ><%=i %></option>
            <%}%>
        </select>
        <span style="color:royalblue;margin-left: 250px;">
            <%= (current_page-1) * num_every_page + 1%>
            -
            <%=Math.min(current_page * num_every_page, sum)%>
            共<%=sum %>条
            </span>
        <script>page_initial();</script>
    </form>
</div>

</body>
</html>
